﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace MDCAdminTool.Commands
{
    public class CopyCommand : CommandBinding
    {
        public CopyCommand()
        {
            Command = Application.Current.Resources["CopyCommand"] as ICommand;
            CanExecute += OnCanExecute;
            Executed   += OnExecuted;
        }

        protected void OnExecuted( object sender , ExecutedRoutedEventArgs e )
        {
            var text = e.OriginalSource as ListBoxItem;

            Clipboard.SetText( text.Content.ToString() );
        }
        protected void OnCanExecute( object sender , CanExecuteRoutedEventArgs e )
        {
            e.CanExecute = true;
        }
    }
}